﻿package KK.GameBase {
	import KK.GameBase.BaseUI;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class MessageBase extends BaseUI{ 

		public function MessageBase() {
			// constructor code
			init();
		}
		private function init():void
		{
			
		}
		
		override protected function initMC():void
		{
			super.initMC();
			var mc:MovieClip=MovieClip(this.mc);
			
			if(mc.title!=null)
			{
				SetButton(mc.title);
				mc.title.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown);
				mc.title.addEventListener(MouseEvent.MOUSE_UP,MouseUp);
			}
			if(mc.close!=null)
			{
				SetButton(mc.close);
				mc.close.addEventListener(MouseEvent.MOUSE_UP,MouseUp);
			}
		}
		
		private function MouseUp(event:MouseEvent):void
		{
			//super.MouseUp(event);
			var mc:MovieClip=MovieClip(mc);
			switch(event.currentTarget.name)
			{
				case "title":
					mc.title.parent.stopDrag();
				break;
				case "close":
					mc.parent.visible=false;
					mc.dispatchEvent(new Event("btn_close"));
				break;
				default:
				break;
			}
		}
		private function MouseDown(event:MouseEvent):void
		{
			Object(mc).title.parent.startDrag(); 
		}
		
	}
	
}
